1 Imports System.Data.SqlClient
2 Imports System.Security.Cryptography
3 Imports System.IO
4 Imports System.Text
5 Imports System.Collections.Generic
6 Imports System.Net
7 Imports System.Web
8
9 Module ModFunc
10 Public Function CheckForInternetConnection() As Boolean
11 Try
12 Using client = New WebClient()
13 Using stream = client.OpenRead("http://www.google.com")
14 Return True
15 End Using
16 End Using
17 Catch
18 Return False
19 End Try
20 End Function
21
22 Sub LogFunc(ByVal st1 As String, ByVal st2 As String)
23 con = New SqlConnection(cs)
24 con.Open()
25 Dim cb As String = "insert into Logs(UserID,Date,Operation) VALUES (@d1,@d2,@d3)"
26 cmd = New SqlCommand(cb)
27 cmd.Connection = con
28 cmd.Parameters.AddWithValue("@d1", st1)
29 cmd.Parameters.AddWithValue("@d2", System.DateTime.Now)
30 cmd.Parameters.AddWithValue("@d3", st2)
31 cmd.ExecuteReader()
32 con.Close()
33 End Sub
34 Sub SMSFunc(ByVal st1 As String, ByVal st2 As String, ByVal st3 As String)
35 st3 = st3.Replace("@MobileNo", st1).Replace("@Message", st2)
36 Dim request As HttpWebRequest
37 Dim response As HttpWebResponse = Nothing
38 Dim myUri As New Uri(st3)
39 request = DirectCast(WebRequest.Create(myUri), HttpWebRequest)
40 response = DirectCast(request.GetResponse(), HttpWebResponse)
41 End Sub
42 Public Function Encrypt(password As String) As String
43 Dim strmsg As String = String.Empty
44 Dim encode As Byte() = New Byte(password.Length - 1) {}
45 encode = Encoding.UTF8.GetBytes(password)
46 strmsg = Convert.ToBase64String(encode)
47 Return strmsg
48 End Function
49
50 Public Function Decrypt(encryptpwd As String) As String
51 Dim decryptpwd As String = String.Empty
52 Dim encodepwd As New UTF8Encoding()
53 Dim Decode As Decoder = encodepwd.GetDecoder()
54 Dim todecode_byte As Byte() = Convert.FromBase64String(encryptpwd)
55 Dim charCount As Integer = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length)
56 Dim decoded_char As Char() = New Char(charCount - 1) {}
57 Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0)
58 decryptpwd = New [String](decoded_char)
59 Return decryptpwd
60 End Function
61 Sub RefreshRecords()
62 Dim obj As frmMainMenu = DirectCast(Application.OpenForms("frmMainMenu"), frmMainMenu)
63 obj.Getdata()
64 obj.DataGridView1.Refresh()
65 obj.DataGridView1.Update()
66 End Sub
67 End Module